package com.zzw.controller;

import com.zzw.service.impl.SearchServiceImpl;
import com.zzw.utils.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by David on 2017/12/15.
 */

@Controller
@RequestMapping("/teacher")
public class TeacherController {

    @Resource
    private SearchServiceImpl searchService;

    /**
     * desc：通过教师姓名查找是否有这个教师
     */
    @ResponseBody
    @RequestMapping("searchTeacherName")
    Result<String> searchTeacherName(String teachername) {


        String teacherId = searchService.searchTeacherName(teachername);


        Result<String> stringResult = new Result<String>();

        if (teacherId == null) {
            stringResult.setCode(202);
            stringResult.setData(teacherId);
            stringResult.setMsg("查找失败");
        } else if (teacherId != null) {
            stringResult.setCode(0);
            stringResult.setData(teacherId);
            stringResult.setMsg("查找成功");
        }

        return stringResult;
    }
}
